home *** CD-ROM | disk | FTP | other *** search
/ Cream of the Crop 20 / Cream of the Crop 20 (Terry Blount) (1996).iso / program / n_b_v203.zip / A-READER.TXT < prev    next >
Text File  |  1996-07-04  |  8KB  |  132 lines

  1.     ┌──────────────────────────╖                        PowerBASIC v3.20
  2.  ┌──┤          DASoft          ╟──────────────────────┬──────────────────╖
  3.  │  ├──────────────────────────╢    Copyright 1995    │ DATE: 1995-10-01 ╟─╖
  4.  │  │ FILE NAME   A-READER.DMO ║          by          ╘════════════════─ ║ ║
  5.  │  │                          ║  Don Schullian, Jr.                     ║ ║
  6.  │  ╘══════════════════════════╝                                         ║ ║
  7.  │ A license is hereby granted to the holder to use this source code in  ║ ║
  8.  │ any program, commercial or otherwise,  without receiving the express  ║ ║
  9.  │ permission of the copyright holder and without paying any royalties,  ║ ║
  10.  │ as long as this code is not distributed in any compilable format.     ║ ║
  11.  │  IE: source code files, PowerBASIC Unit files, and printed listings   ║ ║
  12.  ╘═╤═════════════════════════════════════════════════════════════════════╝ ║
  13.    │                ....................................                   ║
  14.    ╘═══════════════════════════════════════════════════════════════════════╝
  15.  
  16.   Welcome to the world of pixels!   Throughout this section we will be
  17. referring to "Icons", "Planes", and "Buffers". Simply put an "Icon" is
  18. stored bit-map data for an image.  An Icon is a 2 dimensional item but
  19. can be displayed on or captured from a color screen quite easily. That
  20. brings us to "Planes". Monochrome screens possess only 1 plane and are
  21. 2 dimensional. The CGA screen has 4 colors and as it requires two bits
  22. to count to 4 (0,1,2,3) there are 2 planes for the CGA screen. The VGA
  23. screen (12) has 16 colors and, applying the same logic, 4 planes. Easy
  24. hugh!  When data is moved off of or onto a screen we use a "Buffer" to
  25. hold it. This buffer could be a BYTE array, WORD array, MEMORY or even
  26. a STRING. You may use whichever best suits your program(ing).  Each of
  27. the buffers have 2bytes for the number of columns, 2bytes for the rows
  28. and XXbytes of data.  Each pixel of the data represents a pixel on the
  29. screen (about).
  30.  
  31.   Just in case you've not noticed, all the screens are an exact number
  32. of BYTEs wide.  A byte is the smallest unit that a language can easily
  33. manipulate. So, what's this gotta do with icons? Well, if your icon is
  34. 64 pixels wide instead of 65 and you PUT that icon at column 8 instead
  35. of column 7 it will be a lot faster job because  bits don't have to be
  36. shifted from one byte to another  to get the image into  screen memory
  37. which can only accept a full byte at a time. Get it? These columns are
  38. called "byte binderies" and should be used as often as possible. Video
  39. memory is also arranged in planes with plane#1 following plane#0, etc.
  40. This, of course, is for color screens like CGA and VGA (monochrome has
  41. only 1 plane).
  42.  
  43.   Icons, as I have stated,  are only 2 dimensional so how can we use a
  44. color screen? The most used icons are fonts/letters. These are usually
  45. PUT on the screen in one color over another color (background). If you
  46. know that you are  only supposed to put those  pixels in the icon that
  47. are "on" and the "on" color is N° 14 then it is quite simple.  When an
  48. icon has more  than one color  then you must start working with planes
  49. and when the icon,  like a letter,  must allow the  background to show
  50. through then you must use a  fifth plane called a MASK.  Remember that
  51. the VGA screen has 4  planes and each plane is stored consecutively in
  52. memory. This is the reason for the PutPlane and GetPlane routines.
  53.  
  54.         ┌───────────────────  < plane 3     76543210 - bit numbers
  55.         │ 4 0
  56.        ┌┴──────────────────   < plane 2
  57.        │ 5 1
  58.       ┌┴─────────────────     < plane 1
  59.       │ 6 2
  60.      ┌┴────────────────       < plane 0            (fig.12,302)
  61.      │ 7 3
  62.  
  63.      The 4 planes in memory are stores consecutively and bits are
  64.      put in the order as shown using the numbers. Remember that bits
  65.      are counted right to left with bit 0 being the right-most.
  66.  
  67.   The gripe about SCREEN 12 is: "It has only 16 colors!".  This is not
  68. exactly true! You can use 65,536 colors on your VGA screen but only 16
  69. of them at once.  If you are trying to recreate a Picasso then you are
  70. going to have some problems but  simple games  and applications should
  71. have absolutely no problems with only 16 colors.  You can even do some
  72. very descent  3-D work by  rearranging the values in the  DAC register
  73. and using color masks  to create visual effects.  Try the 50/50 mix of
  74. the two blues one time!  The thing I like best about  SCREEN 12 is its
  75. popularity, resolution and universal standards.
  76.  
  77.   While I'm at it, there are also some cute little routines that allow
  78. manipulate icon data to create some "special effects". ShearIcon, when
  79. used with letters creates italics. Forward and backward facing italics
  80. can be created or, the "aspect" can be simply changed of an image by a
  81. quick pass through ShearIcon. Then there is BlowIcon which will make a
  82. bigger copy of what you've captured.
  83.  
  84.   All the routines that put, draw,  or get things from the screen will
  85. accept "illegal" numbers like -10 and 800! When this happens that part
  86. of the icon is simply ignored.  This handy trick allows you to make an
  87. icon slide onto or off of the screen without major bit shifting! There
  88. is also a  SetViewWindow  which allows you to manually set the area of
  89. the screen that will be affected while  anywhere outside of the box is
  90. "off limits" to these routines!
  91.  
  92.   All the routines work on a  LeftCol%, TopRow%, RightCol%, BottomRow%
  93. logic. These variables may be noted as X1%, Y1%, X2%, Y2%  or C1%, R1%
  94. C2%, R2%  depending on how the spirit moved me when I was writing it,
  95. but they all mean the same thing. Some of the routines will accept the
  96. addresses by sending the starting element of an array.  The arrays are
  97. DIMed E%(0:3,0:xx), E%(0:3), E%(1:4,1:xx), E%(1:4) etc. This will keep
  98. the C1%, R1%, C2%, R2%  info inline in memory and can be pulled off by
  99. the routines.
  100.    DIM E%(3,10) : E%(0,0) = LeftCol%  :  E%(2,0) = RightCol%
  101.                   E%(1,0) = TopRow%   :  E%(3,0) = BottomRow%
  102.  
  103.    Do NOT make the mistake of diming the array E%(0:4,0:xx) as this
  104.    leaves room for 5 elements for each box and not the required 4!
  105.  
  106.   The mouse is NOT supported in any of the routines in the DAS-NBV?
  107. libraries as it is a rare occasion, indeed, that only 1 of the routines
  108. would be called by itself. Usually you would call a group of them to
  109. create an image, draw a box, etc. Then, after you've got your box you
  110. have to print, draw or put something in it so you would be calling the
  111. mouse on/off all the time for no purpose. It would also knock off a few
  112. 1000s of a second and increase the code size, so, do your thing. Just
  113. remember:     asm mov ax,&h01   ; turns the mouse on
  114.               asm int &h33
  115.               '──────────────────  and
  116.               asm mov ax,&h02
  117.               asm int &h33      ; turns it off
  118.  
  119.               these 2 two-liners in ASM are about 60 bytes cheaper
  120.               than calling MouseON and MouseOFF but you HAVE to use
  121.               them in pairs or you will, at some time, loose the mouse
  122.  
  123.   And, last but not least,  there is a plethora  of second level stuff
  124. that will allow you to quickly draw 3D boxes, text boxes, print to the
  125. screen using your character sets and even some routines to draw stars,
  126. polygons, etc. There is even a large selection of two color/monochrome
  127. masks ready to use for backgrounds and borders.  All five PutModes are
  128. supported by most of these routines. In short this library is a pretty
  129. complete package of graphics routines.  Hope you find it as productive
  130. as I have!
  131.  
  132.